package com.aura.blog.common.util;

import com.aura.blog.dto.request.AddBlogRequest;
import com.aura.blog.dto.request.UpdateBlogRequest;
import com.aura.blog.dto.response.BlogInfoResponse;
import com.aura.blog.dto.response.UserInfoResponse;
import com.aura.blog.entity.BlogInfo;
import com.aura.blog.entity.UserInfo;
import org.springframework.beans.BeanUtils;

public class BeanTransUtils {
    /**
     * 将BlogInfo对象转换为BlogInfoResponse对象
     * 
     * @param blogInfo 博客信息对象
     * @return 博客信息响应对象
     */
    public static BlogInfoResponse trans(BlogInfo blogInfo){
        BlogInfoResponse response = new BlogInfoResponse();
        BeanUtils.copyProperties(blogInfo, response);
        return response;
    }

    /**
     * 将UserInfo对象转换为UserInfoResponse对象
     * 
     * @param userInfo 用户信息对象
     * @return 用户信息响应对象
     */
    public static UserInfoResponse transUser(UserInfo userInfo){
        UserInfoResponse response = new UserInfoResponse();
        BeanUtils.copyProperties(userInfo, response);
        return response;
    }

    /**
     * 将AddBlogRequest对象转换为BlogInfo对象
     * 
     * @param blogRequest 添加博客请求对象
     * @return 博客信息对象
     */
    public static BlogInfo transBlogInfo(AddBlogRequest blogRequest){
        BlogInfo response = new BlogInfo();
        BeanUtils.copyProperties(blogRequest, response);
        return response;
    }

    /**
     * 将UpdateBlogRequest对象转换为BlogInfo对象
     * 
     * @param blogRequest 更新博客请求对象
     * @return 博客信息对象
     */
    public static BlogInfo transBlogInfo(UpdateBlogRequest blogRequest){
        BlogInfo response = new BlogInfo();
        BeanUtils.copyProperties(blogRequest, response);
        return response;
    }

}
